package com.jintoufs.weixin.recommend;

import com.jintoufs.domain.images.Images;
import com.jintoufs.interceptor.ParamCheck;
import com.jintoufs.service.image.ImageService;
import com.jintoufs.service.scene.SceneService;
import com.jintoufs.weixin.SupportAction;
import com.jintoufs.service.hotel.HotelService;
import org.cosmos.modules.web.msg.AjaxMsg;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by pengyang on 2017/12/26.
 */
@Scope("prototype")
@RestController
@RequestMapping("/recommends")
public class RecommendAction extends SupportAction{

    @Resource
    private HotelService hotelService;


    @Resource
    private SceneService sceneService;

    private ImageService imageService;

    @ParamCheck(params = "type")
    @GetMapping
    public AjaxMsg getRecommends(String type) {
        AjaxMsg ajaxMsg = new AjaxMsg();
        Map<String,Object> param = new HashMap<>();
        try{
            switch (type){
                case "1005001":
                    //查询鱼·定制推荐
                    List<Map<String,Object>> recommendList = sceneService.getRecommends(new HashMap());
                    Map<String,Object> params = new HashMap<>();
                    //查询鱼·定制价格
                    //查询鱼·定制图片
                    ajaxMsg.setDatas(recommendList);
                    break;
                case "1005000":
                    param.put("recommend","1");
                    List<Map<String,Object>> hotels = hotelService.queryByParams(param);
                    ajaxMsg.setDatas(hotels);
                    break;
                    default:
                        break;
            }
        } catch (Exception e) {
            e.printStackTrace();
            ajaxMsg.setCode(AjaxMsg.FAILURE);
            ajaxMsg.setMessage(e.getMessage());
            return ajaxMsg;
        }
        return ajaxMsg;
    }
}
